<?php

class admin_home extends CI_Controller {

	function __construct() {
		parent::__construct();
		$this->load->model('login_Model', '', TRUE);
	}

	function index() {
		if ($this->session->userdata('logged_in')) {
			$session_data = $this->session->userdata('logged_in');
			$data['login'] = $session_data['login'];
			$data['id'] = $session_data['id'];
			$data['first'] = $session_data['first'];
			$data['last'] = $session_data['last'];
			$data['email'] = $session_data['email'];
			$this->load->view('admin_home', $data);
		}
		else {
			redirect('login', 'refresh');
		}
	}

	function logout() {
		$this->session->unset_userdata('logged_in');
		$this->session->sess_destroy();
		redirect('login', 'refresh');
	}
	
	function product_list() {
		redirect('product_list', 'refresh');
	}
	
	function order_list() {
		redirect('order_list', 'refresh');
	}
	
	function deleteAll() {
		$this->session->set_flashdata('deletion_message', 'Deleted all Customers and Orders!');
		$this->db->empty_table('order');
		$this->db->empty_table('order_item');
		$id = "admin";
		$this->db->where('first !=', $id);
		$this->db->delete('customer');
		redirect('admin_home', 'refresh');
	}
}